import md5 from 'js-md5';
import config from '@/config.js'
const sign = function(params={}){

	const timestamp = Date.parse(new Date()) / 1000;  //当前时间戳
	let array = [];
	let str = '';

    params["timestamp"] = timestamp;
	let keys_array=Object.keys(params);
	keys_array.sort();
	keys_array.forEach(i => {
		array.push(i + params[i].toString());
	});
	// array.sort();
    array.forEach(i => {
		str += i;
	});
	str = md5(str + config.sign_key).toString().toUpperCase();
	params['sign'] = str;
	return params;
}

export default sign
